Skip to main content
Executes a shell command in the isolated sandbox environment associated with a room. Unlike the message endpoint, this executes commands directly without AI interpretation.

Endpoint

Path Parameters

string
required
Unique identifier for the room. Each room has its own isolated sandbox instance named sandbox-{roomID}.

Request Body

string
required
The shell command to execute. Must be at least 1 character long.

Response

ExecResult
The execution result containing stdout and stderr streams.
string
The name of the sandbox instance that executed the command (format: sandbox-{roomID}).

Example Request

Example Response

Error Responses

400 Bad Request

Returned when request validation fails:

404 Not Found

Returned when the room ID is missing or the endpoint path is incorrect.

405 Method Not Allowed

Returned when using a method other than POST.

500 Internal Server Error

Returned when sandbox execution fails:

Use Cases

  • Direct command execution for scripting and automation
  • Testing and debugging sandbox environments
  • File system operations in the isolated environment
  • Running build commands or test suites

Implementation Reference

The handler uses Cloudflare’s sandbox API:

Sandbox Lifecycle

Each room has a persistent sandbox instance that:
  • Is created on first use
  • Maintains file system state between commands
  • Is isolated from other rooms’ sandboxes
  • Can be destroyed using the DELETE /api/rooms/ endpoint